﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Payments.aspx.cs" Inherits="Operator_Payments" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">

 <br />
    <asp:HyperLink ID="OperatorsLink" runat="server" NavigateUrl="~/Operator/OperatorPanel.aspx">Панель оперетора</asp:HyperLink>&nbsp;→&nbsp;
    <asp:Label ID="Label1" runat="server" Text="Найти кредит для оплаты" Font-Bold="true"></asp:Label>
    <br />
    <br />

<br />
<table>
<tr>
<td>
    <asp:Label ID="Label" runat="server" Text="Номер договора"></asp:Label>
</td>
<td>
 <asp:TextBox ID="ContractNumber" runat="server"></asp:TextBox>
 <asp:RequiredFieldValidator ControlToValidate="ContractNumber" CssClass="failureNotification"
                    Display="Dynamic" ID="CurrencyUSDValidator" runat="server" ValidationGroup="CurrencyValidationGroup">*</asp:RequiredFieldValidator>
            
            <asp:RegularExpressionValidator runat="server" ID="MoneyValidator2" ControlToValidate="ContractNumber"
                    Text="Введите целое положительное число." Display="Dynamic" ForeColor="Red" ValidationExpression="(^[1-9][0-9]*$)"
                    ValidationGroup="RegisterMoneyValidationGroup" />
</td>
<td>
    <asp:Button ID="FindContractButton" runat="server" Text="Найти" 
        onclick="FindContractButton_Click" />
</td>
</tr>
</table>
<br />
    <asp:GridView ID="GridViewContracts" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="Номер договора" DataSourceID="SqlDataSourceContracts" 
        Visible="False" onrowdatabound="GridViewContracts_RowDataBound">
        <Columns>
            <asp:BoundField DataField="Номер договора" HeaderText="Номер договора" 
                InsertVisible="False" ReadOnly="True" SortExpression="Номер договора" />
            <asp:BoundField DataField="Предприятие" HeaderText="Предприятие" 
                SortExpression="Предприятие" />
            <asp:BoundField DataField="Сумма" HeaderText="Сумма" SortExpression="Сумма" />
            <asp:BoundField DataField="Валюта" HeaderText="Валюта" 
                SortExpression="Валюта" />
            <asp:BoundField DataField="Кредит" HeaderText="Кредит" 
                SortExpression="Кредит" />
            <asp:BoundField DataField="Дата заключения" HeaderText="Дата заключения" 
                SortExpression="Дата заключения" />
                <asp:BoundField HeaderText="Оплачено по основному долгу" />
            <asp:BoundField HeaderText="Оплачено по процентам" />
                <asp:TemplateField>
                            <ItemTemplate>
                                <asp:LinkButton ID="PayLink" runat="server" OnClick="PayClicked">Оплатить</asp:LinkButton>
                            </ItemTemplate>
                            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            Нет договоров с данным номером.
        </EmptyDataTemplate>
    </asp:GridView>
    
   <asp:SqlDataSource ID="SqlDataSourceContracts" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
        SelectCommand="SELECT Contract.ContractId AS [Номер договора], Company.CompanyName AS Предприятие, Contract.Amount AS Сумма, Currency.Name AS Валюта, Credit.Name AS Кредит, Contract.CreationDate AS [Дата заключения] FROM Contract INNER JOIN Credit ON Contract.CreditId = Credit.CreditID INNER JOIN Currency ON Contract.CurrencyId = Currency.CurrencyID INNER JOIN Status ON Contract.StatusId = Status.StatusId INNER JOIN Company ON Contract.CompanyId = Company.CompanyId WHERE (Contract.StatusId = 1) AND (Contract.ContractId = @ContractId)">
        <SelectParameters>
            <asp:Parameter Name="ContractId" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>

